<%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="/ms-tags" prefix="ms"%>
<c:import url= "/public/include/msDocType.html"/>
<html>
  <head>
  	<c:import url="/common/base-hplus.jsp" /> 
    <script type="text/javascript">
     function saveRolePrivate(roleCode){
    	 var str = document.getElementsByName("menuCode");
    	    var objarray=str.length;
    	    var chestr="";
    	    for (i=0;i<objarray;i++){
    	          if(str[i].checked == true){
    	               chestr+=str[i].id+",";
    	          }
    	    }
   	   		var saveUrl = "/system/role/tMgtRole/saveRolePrivate.do";
   	   		
	   	   	$.SwalAjaxRequestHelper.AjaxRequest(saveUrl, {"roleCode":roleCode, "menusStr":chestr}, function(data) {
		   		 swal({
		   	     	title: "系统提示",
		   	        text: data.message,
		   	        type: "info",
		   	        confirmButtonColor: "#DD6B55",
		   	        confirmButtonText: "确定",
		   	        closeOnConfirm: true
		   		 }, function () {
		   	    	$.SystemHelper.ReloadParentPage();
		   		 });
		   	});
   	   	
     }
    </script>
  </head>
  
  <body>
    
   	 <div class="wrapper wrapper-content animated fadeInRight">	
	 	
				 <div class="row">
				 
            <div class="col-sm-12">
                  
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form id="roleForm" name="roleForm" method="post" action="" class="form-horizontal">
							<input type="hidden" name="id" id="id" value="${role.id}" />
                            <div class="form-group">
                                <label class="col-sm-2 control-label">角色编码</label>
                                <div class="col-sm-4">
									<ms:input name="userId" value="${role.roleCode}" cssClass="form-control" readOlny="true"/>
                                </div>
                                <label class="col-sm-2 control-label">角色名称</label>
                                <div class="col-sm-4">
                                    <ms:input name="userName" value="${role.roleName}" cssClass="form-control" readOlny="true"/>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            
                            <c:forEach items="${menus}" var="menu"  varStatus="st">
                            <c:if test="${menu.menuLevel==1 }">
                            <div class="form-group">
	                                <label class="col-sm-2 control-label">${menu.menuName }</label>
	                                <div class="col-sm-10">
	                                     <c:forEach items="${menus}" var="menuSon"  varStatus="stx">
	                                      <c:if test="${menuSon.upMenuCode==menu.menuCode }">
											<c:set var="checkedValue" value="" />
					            	 			<c:forEach items="${rolePrivates}" var="rolePrivates"  varStatus="stxx">
					            	 			<c:if test="${rolePrivates.menuCode == menuSon.menuCode }">
						            	 			<c:set var="checkedValue" value="checked" />
												</c:if>
				            	 			</c:forEach>
				            	 			<div class="checkbox i-checks" style="float:left">
	                                        	<label><input id="${menu.menuCode }_${menuSon.menuCode}" name="menuCode"  type="checkbox" value="${role.roleCode}" ${checkedValue }> <i></i> ${menuSon.menuName }</label>
	                                    	</div>
	                                    	</c:if>
							        	</c:forEach>
	                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            </c:if>
                            </c:forEach>
                            
                            <div class="input-group">
								<span class="input-group-btn">
									<button id="btnListQuery" type="button" onclick="saveRolePrivate('${role.roleCode}')" class="btn btn-sm btn-primary">保存</button>	
								</span>
							</div>
                            

                        </form>
                    </div>
                </div>
            </div>
		</div>	
	</div>			
	
	<script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
    </script>
                  
  </body>
</html>